package com.pruebas.physics;

import com.pruebas.physics.dragablemomentumsimplegravity.DragableMomentumSimpleGravityActivity;
import com.pruebas.physics.dragableworldgravity.DragableWorldGravityActivity;
import com.pruebas.physics.rotatingcube.RotatingCubeActivity;
import com.pruebas.physics.simplegravity.SimpleGravityActivity;
import com.pruebas.physics.simplegravityandcollision.SimpleGravityAndCollisionActivity;
import com.pruebas.physics.worldgravityandcollision.WorldGravityAndCollisionActivity;


import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class MainActivity extends ListActivity {
	
	private String[] activitiesNames = {
			"SimpleGravity", "SimpleGravityAndCollision",
			"WorldGravityAndCollision", "DragableWorldGravity",
			"DragableMomentumSimpleGravity", "RotatingCube"			
	};
	private Class<?>[] activities = {
			SimpleGravityActivity.class, SimpleGravityAndCollisionActivity.class,
			WorldGravityAndCollisionActivity.class, DragableWorldGravityActivity.class,
			DragableMomentumSimpleGravityActivity.class, RotatingCubeActivity.class
	};
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setListAdapter(new ArrayAdapter<String>(this, R.layout.main, activitiesNames));
        
        ListView lv = getListView();
		lv.setTextFilterEnabled(true);
        
		lv.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View view,
		        int position, long id) {
				Intent intent = new Intent(view.getContext(), activities[position]);
				startActivityForResult(intent, 0);
		    }
		});
    }
}